package org.adultedu.controller;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.adultedu.pojo.ScList;
import org.adultedu.result.Result;
import org.adultedu.result.ResultUtil;
import org.adultedu.service.ScListService;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;


@CrossOrigin
@RestController
public class ScListController {

    @Autowired
    private ScListService scListService;

    @GetMapping(value = "/getOrderList")
    public Result getOrderList(String scid, Integer ispay,String startdate, String enddate) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date s = sdf.parse(startdate);
        Date e = sdf.parse(enddate);
        return ResultUtil.success(scListService.queryScListByDate(s,e,ispay));
    }

    @GetMapping(value = "/getList")
    public Result getList(String scid, Integer ispay){
        return ResultUtil.success(scListService.queryScList(ispay));
    }
}
